home *** CD-ROM | disk | FTP | other *** search
- Path: news.interport.net!usenet
- From: jeremy <jeremy@interport.com>
- Newsgroups: comp.lang.c
- Subject: HELP: Floating point precision
- Date: Fri, 08 Mar 1996 13:57:31 -0500
- Organization: Xyris Software, Inc.
- Message-ID: <3140831B.1597@interport.com>
- NNTP-Posting-Host: jeremy.port.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- The mechanism for casting 4-byte float to 8-byte double is
- causing me some problems. The following code:
-
- float f;
- double d;
- f = 1.332;
- d = (double) f;
-
- results in:
-
- f = 1.33200
- d = 1.3320000171661
-
- (I am using Microsoft Visual C++ 2.1 compiler).
-
- I understand that this is due to complexities in
- floating-point storage beyond my ken. Is there any run-time
- library function which would cast f to 1.3320000000000 ? If not,
- does anyone know how to write such a function? Using a lot of
- processor cycles is not a big issue in the place I am having
- this problem; I could afford to waste a little time.
-
- Thanks!
- Jeremy
-